package cn.glow.readingcloud.account.feign.fallback;


import cn.glow.readingcloud.account.feign.client.LikeSeeClient;
import cn.glow.readingcloud.common.result.Result;
import cn.glow.readingcloud.common.result.ResultUtil;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Author Glow
 * @Date 2023-04-16 14:54:41
 * @Description
 * @Version 1.0
 */
public class LikeSeeClientFallBack  implements FallbackFactory<LikeSeeClient> {
    private static final Logger LOGGER = LoggerFactory.getLogger(LikeSeeClientFallBack.class);

    @Override
    public LikeSeeClient create(Throwable throwable) {
        return new LikeSeeClient() {
            @Override
            public Result<Integer> getBookLikesCount(String bookId) {
                LOGGER.error("获取喜欢看[{}]数量失败：{}", bookId, throwable.getMessage());
                return ResultUtil.notFound(0);
            }
        };
    }
}
